package com.wzdigit.wms.raw.controller.sap;

import com.wzdigit.framework.exception.RestStatusException;
import com.wzdigit.framework.model.response.ErrorEntity;
import com.wzdigit.wms.basic.client.Pager;
import com.wzdigit.wms.basic.client.PagerInfo;
import com.wzdigit.wms.basic.client.request.transfer.CommitTransferReq;
import com.wzdigit.wms.basic.client.request.transfer.SearchTransferTaskRequest;
import com.wzdigit.wms.basic.client.response.Result;
import com.wzdigit.wms.basic.client.response.transfer.*;
import com.wzdigit.wms.raw.client.response.asn.report.ortherasn.OrtherAsnEnums;
import com.wzdigit.wms.raw.constant.RawWareConstant;
import com.wzdigit.wms.raw.domain.dto.SapStoreDto;
import com.wzdigit.wms.raw.service.sap.SapStoreService;
import com.wzdigit.wms.raw.service.transfer.TransferAutoService;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
    *获取SAP库存服务
    * @author shuaic
    * @date 2021/8/26 15:59
*/
@Slf4j
@RestController
@RequestMapping(value = RawWareConstant.API_VERSION)
@Api(tags = "获取SAP库存")
public class SapStoreController {
    public static final String REQUEST_MODEL = "/sapstore";

    @Autowired
    private SapStoreService sapStoreService;

    @ApiOperation(value = "获取SAP库存", notes = "获取SAP库存")
    @ApiResponses({@ApiResponse(code = 500, message = "系统出现异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUEST_MODEL + "/getstore")
    public List<SapStoreDto> getSapStore(
            @ApiParam("工厂")
            String factory,
            @ApiParam("物料编码")
            String skuCode,
            @ApiParam("仓库ID")
            Integer wareHouseId,
            @ApiParam("品质状态")
            Integer status,
            HttpServletRequest servletRequest,
            HttpServletResponse servletResponse) {
        try {
            return sapStoreService.getSapStore(factory,skuCode,wareHouseId,status);
        } catch (RestStatusException e) {
            e.printStackTrace();
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw e;
        }
    }

}
